package io.persimmon.core.module;

import io.persimmon.core.module.call.Callback;
import io.persimmon.core.module.call.Runback;
import io.persimmon.core.module.id.DefaultIDFactory;
import io.persimmon.core.module.lock.Lock;
import io.persimmon.core.module.lock.LockFactory;
import io.persimmon.core.module.log.CostLog;
import io.persimmon.core.module.schedule.MultipleScheduleTask;
import io.persimmon.core.module.schedule.ScheduleTaskFactory;

public class PersimmonModule {
    public String createUUId() {
        return DefaultIDFactory.UUID.createId();
    }

    public long createLongId() {
        return DefaultIDFactory.SNOW_FLAKE_ID.createId();
    }

    public <T> LockFactory<T> createLockFactory(Lock lock) {
        return LockFactory.createLock(lock);
    }

    public MultipleScheduleTask createMultipleScheduleTask(String name) {
        return ScheduleTaskFactory.create(name);
    }

    public MultipleScheduleTask createMultipleScheduleTask(String name, Integer threadCount) {
        return ScheduleTaskFactory.create(name, threadCount);
    }

    public MultipleScheduleTask create(String name, Integer threadCount, Long tickDurationMill, Integer ticksPerWheel) {
        return ScheduleTaskFactory.create(name, threadCount, tickDurationMill, ticksPerWheel);
    }

    public <T> CostLog<T> logCost(Runback runnable) {
        return CostLog.create(runnable);
    }

    public <T> CostLog<T> logCost(Callback<T> callback) {
        return CostLog.create(callback);
    }
}
